﻿namespace Jumbot.Common
{
    using System;
    using System.Runtime.InteropServices;

    [Serializable, StructLayout(LayoutKind.Sequential, Pack=1)]
    public struct Int128
    {
        public static readonly int Size;
        public long Lo;
        public long Hi;
        public byte[] GetBytes()
        {
            byte[] destinationArray = new byte[0x10];
            Array.Copy(BitConverter.GetBytes(this.Lo), 0, destinationArray, 0, 8);
            Array.Copy(BitConverter.GetBytes(this.Hi), 0, destinationArray, 8, 8);
            return destinationArray;
        }

        public static Int128 ToInt128(byte[] buf, int startIndex)
        {
            Int128 num;
            num.Lo = BitConverter.ToInt64(buf, startIndex);
            num.Hi = BitConverter.ToInt64(buf, startIndex + 8);
            return num;
        }

        static Int128()
        {
            Size = 0x10;
        }
    }
}

